package com.ruoyi.drug.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.drug.domain.DrugsOrder;
import com.ruoyi.drug.mapper.DrugsOrderMapper;
import com.ruoyi.drug.service.IDrugsOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 订单
 * Service业务层处理
 *
 * @author ruoyi
 * @date 2022-11-14
 */
@Service
public class DrugsOrderServiceImpl implements IDrugsOrderService {
    @Autowired
    private DrugsOrderMapper drugsOrderMapper;

    /**
     * 查询订单
     *
     * @param orderId 订单
     *                主键
     * @return 订单
     */
    @Override
    public DrugsOrder selectDrugsOrderByOrderId(Long orderId) {
        return drugsOrderMapper.selectDrugsOrderByOrderId(orderId);
    }

    /**
     * 查询订单
     * 列表
     *
     * @param drugsOrder 订单
     * @return 订单
     */
    @Override
    public List<DrugsOrder> selectDrugsOrderList(DrugsOrder drugsOrder) {
        return drugsOrderMapper.selectDrugsOrderList(drugsOrder);
    }

    /**
     * 新增订单
     *
     * @param drugsOrder 订单
     * @return 结果
     */
    @Override
    public int insertDrugsOrder(DrugsOrder drugsOrder) {
        drugsOrder.setCreateTime(DateUtils.getNowDate());
        drugsOrderMapper.insertDrugsOrder(drugsOrder);
        return  Math.toIntExact(drugsOrder.getOrderId());
    }

    /**
     * 修改订单
     *
     * @param drugsOrder 订单
     * @return 结果
     */
    @Override
    public int updateDrugsOrder(DrugsOrder drugsOrder) {
        drugsOrder.setUpdateTime(DateUtils.getNowDate());
        return drugsOrderMapper.updateDrugsOrder(drugsOrder);
    }

    /**
     * 批量删除订单
     *
     * @param orderIds 需要删除的订单
     *                 主键
     * @return 结果
     */
    @Override
    public int deleteDrugsOrderByOrderIds(Long[] orderIds) {
        return drugsOrderMapper.deleteDrugsOrderByOrderIds(orderIds);
    }

    /**
     * 删除订单
     * 信息
     *
     * @param orderId 订单
     *                主键
     * @return 结果
     */
    @Override
    public int deleteDrugsOrderByOrderId(Long orderId) {
        return drugsOrderMapper.deleteDrugsOrderByOrderId(orderId);
    }
}
